

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object WordCountDemoPlus {
  def main(args: Array[String]): Unit = {
    //词频统计
    //创建Spark Context对象
    //创建配置对象
    //去掉本地模式设置
    val conf: SparkConf = new SparkConf().setAppName("wordscount")
    val sc = new SparkContext(conf)
    //设置日志的级别
    sc.setLogLevel("WARN")
    //设置读取数据文件和保存结果数据的路径
    val result: RDD[(String, Int)] = sc.textFile(args(0)).flatMap(_.split(" ")).map((_, 1)).reduceByKey(_ + _)
    result.saveAsTextFile(args(1))

    sc.stop()

  }
}
